from models.user import User
from models.product import Product, ProductCategory  
from models.payment import PaymentMethod
from services.transaction_service import TransactionService

def initialize_products():
    return {
        "摄影套餐": Product("摄影套餐", price=15.0, category=ProductCategory.FOOD),
        "猫粮": Product("猫粮", price=50.0, points_cost=100, category=ProductCategory.FOOD),
        "宠物养护": Product("宠物养护服务", points_cost=40, category=ProductCategory.SERVICE),
        "体验套餐": Product("体验套餐", coupon_cost=2, category=ProductCategory.SERVICE)
    }

def initialize_users():
    return {
        "小明": User("小明" ),
        "小红": User("小红"),
        "小花": User("小花"),
        "小黑": User("小黑"),
        "小黄": User("小黄")
    }

def create_sample_transactions(service, users, products):
    service.create_transaction(users["小明"], "点餐页面", products["摄影套餐"], 2, PaymentMethod.BALANCE)
    service.create_transaction(users["小红"], "商城页面", products["猫粮"], 1, PaymentMethod.CASH)
    service.create_transaction(users["小花"], "积分兑换页面", products["宠物养护"], 1, PaymentMethod.POINTS)
    service.create_transaction(users["小黑"], "积分兑换页面", products["猫粮"], 3, PaymentMethod.POINTS)
    service.create_transaction(users["小黄"], "优惠券页面", products["体验套餐"], 1, PaymentMethod.COUPON)

def display_results(service, users):
    print("========== 交易记录 ==========")
    for i, tx in enumerate(service.get_all_transactions(), 1):
        print(f"{i}. {tx}")
    

def main():
    # 初始化
    products = initialize_products()
    users = initialize_users()
    service = TransactionService()
    
    # 创建交易
    create_sample_transactions(service, users, products)
    
    # 显示结果
    display_results(service, users)

if __name__ == "__main__":
    main()